﻿Public Class Frm3EntradasMenu
    Public Sub cargarRegistros(ByVal fila As Integer)
        Try
            Dim accion As New MovimientosDAO
            'Llenar tabla
            Dim tabla As New DataTable
            Dim datoi As New Movimientos
            datoi.pID_T_Documento = 1
            tabla = accion.mostrar(datoi)
            'Comprobar si hay datos
            If Not tabla Is Nothing Then
                'Cargar datos en el grid
                'dgv1.DataSource = tabla
                FormatosGrid.formatoGrid_Movimientos(DGV1, tabla)
                'Mostrar datos en los controles
                Label1.Text = DGV1.Rows(fila).Cells(0).Value
                DGV1.Rows(fila).Selected = True
                DGV1.CurrentCell = DGV1.Rows(fila).Cells(1)
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Advertencia", MessageBoxButtons.OK,
                        MessageBoxIcon.Warning)
        End Try
    End Sub

    Public Sub cargarDetalle(ByVal fila As Integer)
        Try
            Dim axion As New MovimientosDAO
            Dim dato As New Movimientos
            'Llenar tabla
            dato.pID_Movimiento = Label1.Text
            Dim tabl As New DataTable
            tabl = axion.mostrarDetalle_Entradas(dato)
            FormatosGrid.formatoGrid_Movimientos_Detalles(DGV2, tabl)



        Catch ex As Exception
            MessageBox.Show(ex.Message, "Advertencia", MessageBoxButtons.OK,
                        MessageBoxIcon.Warning)
        End Try
    End Sub

    Private Sub dgv1_CurrentCellChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DGV1.CurrentCellChanged
        Try
            If Not DGV1.CurrentCell Is Nothing Then
                With DGV1
                    Label1.Text = .Rows(.CurrentCell.RowIndex).Cells(0).Value
                End With
                cargarDetalle(Label1.Text)
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Advertencia", MessageBoxButtons.OK,
              MessageBoxIcon.Warning)
        End Try
    End Sub
    Private Sub Frm3Entradas_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cargarRegistros(0)


    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Frm3EntradasAgregar.Show()
        Me.Close()
    End Sub

End Class